package co.com.travelsoft.ati.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@Entity
@NamedQueries( { @NamedQuery(name = "TiposEvento.findAll", query = "select o from TiposEvento o") })
public class TiposEvento implements Serializable {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
    @Column(nullable = true)
    private BigDecimal codigo;
    @Column(nullable = false, unique = true, length = 64)
    private String nombre;
    @OneToMany(mappedBy = "tiposevento")
    private List<Eventos> eventosList;

    public TiposEvento() {
    }

    public TiposEvento(BigDecimal codigo, String nombre) {
        this.codigo = codigo;
        this.nombre = nombre;
    }

    public TiposEvento(TipoEventoDto tipoEventoDto) {
        this.setCodigo(tipoEventoDto.getCodigo());
        this.setNombre(tipoEventoDto.getNombre());
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#getCodigo()
	 */
    
	public BigDecimal getCodigo() {
        return codigo;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#setCodigo(java.math.BigDecimal)
	 */
    
	public void setCodigo(BigDecimal codigo) {
        this.codigo = codigo;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#getNombre()
	 */
    
	public String getNombre() {
        return nombre;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#setNombre(java.lang.String)
	 */
    
	public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#getEventosList()
	 */
    
	public List<Eventos> getEventosList() {
        return eventosList;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#setEventosList(java.util.List)
	 */
    
	public void setEventosList(List<Eventos> eventosList) {
        this.eventosList = eventosList;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#addEventos(co.com.travelsoft.ati.entities.Eventos)
	 */
    
	public Eventos addEventos(Eventos eventos) {
        getEventosList().add(eventos);
        eventos.setTiposevento(this);
        return eventos;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#removeEventos(co.com.travelsoft.ati.iterfaces.entities.Evento)
	 */
    
	public Eventos removeEventos(Eventos eventos) {
        getEventosList().remove(eventos);
        eventos.setTiposevento(null);
        return eventos;
    }

    /* (non-Javadoc)
	 * @see co.com.travelsoft.ati.entities.TipoEvento#toString()
	 */
    
    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append(getClass().getName()+"@"+Integer.toHexString(hashCode()));
        buffer.append('[');
        buffer.append("codigo=");
        buffer.append(getCodigo());
        buffer.append(',');
        buffer.append("nombre=");
        buffer.append(getNombre());
        buffer.append(']');
        return buffer.toString();
    }
}
